Combinatorics and Statistical Mechanics of Integer Partitions

We study the set of integer partitions as a probability space that generates distributions and, in the asymptotic limit, obeys thermodynamics. We view ordered integer partition as a configuration of cluster masses and associate them with the distribution of masses it contains. We organized the set of ordered partitions into a table that forms a microcanonical ensemble and whose columns form a set of canonical ensembles. We define a functional of the distribution (selection functional) that establishes a probability measure on the distributions of the ensemble, study the combinatorial properties of this space, define its partition functions, and show that, in the asymptotic limit, this space obeys thermodynamics. We construct a stochastic process that we call exchange reaction and used it to sample the mean distribution by Mote Carlo simulation. We demonstrated that, with appropriate choice of the selection functional, we can obtain any distribution as the equilibrium distribution of the ensemble.


Introduction
The central element of statistical mechanics is the ensemble and its partition function. The microcanonical ensemble contains all microstates with fixed macroscopic energy, volume, and number of particles. The canonical ensemble is a subset of the microcanonical ("system"), and its complement forms another canonical ensemble (the "bath"). The microcanonical and the canonical partition function are Legendre transformations of each other, and their derivatives generate all thermodynamic properties. This summarizes the thermodynamic formalism of Gibbs [1], a recipe that has proven immensely successful in physics, chemistry, and biology. At the heart of Gibbs's method is the enumeration of microstates, a primitive stochastic variable whose enumeration (multiplicity) is a key element of the method. In the microcanonical ensemble, all microstates are represented in equal numbers; in the canonical ensemble, they are represented in proportion to the Boltzmann factor e −E/k B T , as the same microstate can be paired with several microstates in the bath. These multiplicities fix the probability of the microstate. We may generalize this method and apply it to other types of ensembles of "configurations" that are not physical microstates. The set of integer partitions provides a concrete example of an ensemble whose elements can be enumerated exactly. A partition of integer M into N parts is a list of N positive integers whose sum is M. This list can be viewed as M monomers combined into N clusters (polymers). The number of monomers, dimers, etc., present in the partition represents a possible distribution of clusters. The set of partitions forms an ensemble defined by the macroscopic variables M and N, which, like energy, volume, and the number of particles in statistical mechanics, act as constraints on the microstates that can be accessed by the macroscopic system. Integer partitions appear naturally in population balance problems. In discrete fragmentation [2][3][4], fragments are partitions of the mass that generates them. In closed discrete finite populations, the rearrangement of mass via aggregation and fragmentation events represents a random walk on a space of partitions [5][6][7][8][9][10][11]. If we adopt the view of partitions as a finite sample from a population of elements distributed by some extensive property ("mass"), it should come as no surprise A configuration is characterized by its distribution n = (n 1 , n 2 · · · ), where n k is the number of times integer k appears in configuration (number of clusters with mass k). All distributions in E M,N satisfy the conditions: which fix the zeroth-and first-order moments. The maximum possible cluster in the ensemble is M − N + 1, but we let the upper limit in the summations go to ∞ with the understanding that n i = 0 for all i > M − N − 1. The conditions in Equation (2) are necessary and sufficient: all distributions of configurations in E M,N satisfy these conditions, and conversely, all distributions that satisfy them represent configurations in E M,N .

Microcanonical Table
A visual representation of the microcanonical ensemble is illustrated in Table 1 for M = 7, N = 5. We collect all ordered partitions of M into N parts to form a table  (microcanonical table). The table has N columns and ( M−1 N−1 ) rows, corresponding to the number of configurations of the ensemble. Every column contains the same list of numbers, k = 1 through M − N + 1, which may appear multiple times. We calculate this multiplicity as follows. The number of times element k appears in any one column is equal to the number of ways it may be combined with a list of N − 1 positive integers that contain mass M − k to produce a configuration with N clusters and mass M. The set of these lists is the microcanonical ensemble E M−k,N−1 and contains Ω * M−k,N−1 ordered partitions. Therefore, the number of times integer k appears in each column of the microcanonical table is   1  1  1  1  1  3  1  1  1  1  1  3  1  1  1  1  1  3  1  1  1  1  1  3   2  2  1  1  1  2  1  2  1  1  2  1  1  2  1  2  1  1  1  2  1  2  2  1  1  1  2  1  2  1  1  2  1  1  2  1  1  2  2  1  1  1  2  1  2  1 1 The total number of elements in any column is Ω M,N . Therefore, we have the identity: We also have which expresses the fact that the mean cluster in any column of the table is the same as in  the entire table. Returning to Table 1, the order of rows and columns is not important; permutations in their order produce the same list of configurations. The configurations in Table 1 are grouped by distribution, but in an otherwise arbitrary order. In this example, there are two distributions: n A = (4, 0, 1) with four monomers and one trimer, represented by five configurations; and n B = (3, 2, 0) with three monomers and one dimer, which is represented by ten configurations. In writing distributions in vector form, we understand that all omitted elements are zero.

Multiplicity
Configurations that are permutations of each other have the same distribution. The number of configurations with distribution n is equal to the multinomial factor of the distribution: The multinomial factor represents the intrinsic multiplicity of the distribution, i.e., the number of configurations represented by the distribution. Suppose, however, that the elements of the configuration come in multiple internal variants, for example "color," "shape," "reactivity", or a similar attribute. Variants increase the multiplicity of the distribution. If element i exists in w i variants and distribution n contains n i such elements, the multiplicity of the distribution increases by a factor w n i i . When the variants of all elements are considered, the multiplicity of the distribution increases by the product of these factors: The total multiplicity is the product of W(n) with the intrinsic multiplicity n! and represents the statistical weight of the distribution in the ensemble: W(n) is a functional of n that biases the multiplicity of the distribution in the ensemble. With W(n) = 1, this multiplicity reduces to the intrinsic value n! and the partition function is reduced to Ω * in Equation (1). By allowing W to vary between distributions, we effectively bias the weight of the distribution in the ensemble and gain a degree of freedom in manipulating the ensemble, which will prove useful. It is possible to construct functionals that are more general than that in Equation (8), but the above form has several special properties that make it particularly useful. Among them is that W may be explicitly expressed in terms of the elements of the configuration. Given configuration c = c 1 , c 2 · · · with distribution n, its multiplicity is where w(c i ) is the number of variants of size c i .

Microcanonical Probability
The multiplicity of distribution is the number of times the distribution is represented in the ensemble in all ordered permutations of all variants of its elements. We define the microcanonical probability of the distribution as the ratio of its multiplicity over the total multiplicity in the ensemble: The normalizing constant is the microcanonical partition function, equal to the sum of microcanonical weights in the ensemble: The probability of configuration c in the microcanonical table is and follows from Equation (10) and the fact that all n! permutations with the same distribution are equally probable.
To continue to use the microcanonical table as a visualization of the ensemble, we imagine each configuration in the table to represent W(n) actual configurations; this is the number of ways to build the configuration from all available variants, and it depends on the distribution of elements in the configuration. Therefore, every row of the table is understood to represent W(n) rows, where n is the distribution of the elements in that row.

Mean Distribution
One result that can be obtained very easily from the microcanonical table is the mean distribution of clusters, which we define as the frequency of element k in the ensemble. The mean frequency of clusters of size k in the ensemble is its frequency in any row of the microcanonical table. The number of times cluster size k appears in a row is equal to the number of times it can be combined with a complementary configuration of N − 1 clusters and total mass M − k to form a configuration with N clusters and mass M:. The set of such complements forms the microcanonical ensemble E M−k,N−1 and contains Ω M−k,N−1 elements. Since each cluster in the microcanonical table represents w k variants, the mean cluster distribution is for all M − N + 1 ≥ k ≥ 1. A different derivation of the same result in the context of the zero-range process is given in [12].

Canonical Ensemble
We define the canonical configuration of length N < N as the ordered subset of the first N elements of a microcanonical configuration. The set of all canonical configurations of size N forms the canonical ensemble C N |M,N . The notation emphasizes the fact that the canonical ensemble is defined in the context of an enclosing microcanonical ensemble, and to distinguish between the two, we use primed variables for the canonical ensemble and unprimed for the enclosing microcanonical. The graphical construction of the canonical ensemble is illustrated in Table 2: Form the microcanonical table of the enclosing ensemble, and collect the first N columns. This produces a canonical table with N columns and Ω * M,N rows, each row representing a canonical configuration. In the illustration of Table 2, N = 2. The remaining columns of the microcanonical table form the complementary canonical ensemble C N−N |M,N . Since the ordering of columns in the microcanonical table is immaterial, we could pick any N columns in any order, but for simplicity, we will continue to work with the first N columns of the microcanonical table.

Canonical Probability
When a canonical configuration c with distribution n is cut from a microcanonical configuration c with distribution n, it leaves behind a complementary configuration c with distribution n . The set of complements forms the complementary ensemble C N−N ;M,N , and the two complements together form the enclosing microcanonical ensemble. The sum of two complementary distributions, is a member of the enclosing microcanonical ensemble E M,N . In the language of thermodynamics, C N−N ;M,N is the system, its complement is the "bath", and the enclosing microcanonical ensemble is the universe. We obtain the probability of canonical distribution by a combinatorial calculation. Distribution n and its complement n form a microcanonical distribution n with microcanonical probability There are n !n ! ways out of (n + n )! to combine n and its complement; we obtain the canonical probability by summing the factor P(n + n )n !n !/(n + n )! over all complements n . Using P(n + n ) = (n + n )!W(n + n )/Ω M,N for the microcanonical probability of distribution n + n , we obtain: The summation on the far right is over the microcanonical multiplicities of all distributions with mass M − M and number of particles N − N , and it is equal to the microcanonical partition function Ω M−M ,N−N . This leads to the following result for the canonical probability: The canonical probability is proportional to the microcanonical weight of the distribution, but also depends on the partition functions of the complement and of the enclosing ensemble.
To separate the effect of the enclosing ensemble, we write the canonical probability as Noting that Ω M,N−N /Ω M,N is constant, we define the remaining portion of the expression on the right-hand side as the statistical weight of the canonical configuration: We define the canonical partition function as the sum of canonical weights: with the summation over all canonical distributions. Applying the normalization condition on the canonical probability in Equation (18), we obtain This establishes the relationship between the canonical and the microcanonical partition functions.
Unlike the microcanonical ensemble, in which the multiplicity and the statistical weight are equal, in the canonical ensemble, the two are not equal, but proportional to each other. The canonical multiplicity is the number of times a canonical distribution appears in the enclosing microcanonical table and clearly depends not only on the distribution itself, but also on the size of the enclosing ensemble: the same canonical distribution has higher multiplicity if it is removed from a larger microcanonical ensemble. By basing the definition of the canonical partition function on its statistical weight, rather than its multiplicity, we obtain a quantity that, in the asymptotic limit, is independent of the size of the enclosing ensemble. We derive the asymptotic limit in Section 5.

Mean Canonical Distribution
The mean distribution of the canonical ensemble is obtained trivially: it is the same as that of the canonical ensemble because all columns of the microcanonical table contain the same distribution of clusters: The result is true for all 1 ≤ N ≤ N ≤ M.

Binary Exchange Reaction and Its Graph
We have defined a microcanonical space of configurations with an associated space of distributions. To experiment numerically with this space, we need a method to sample its elements with the correct probability. In this section, we construct such a method in the form of a random walk that visits configurations according to their microcanonical probability in Equation (10). We will then use the method in Section 6 to study the asymptotic behavior of the ensemble and the close relationship between the selection functional and the mostprobable distribution.
We formulate the sampling process as a binary exchange reaction, a process that emulates reactions between physical clusters. Starting with a configuration c, we select two elements, i and j, and exchange the mass between them to create a new pair of clusters i and j under the mass-conserving condition i + j = i + j . The transfer produces a new configuration with the same number of particles and total mass, which we represent by the reaction: The binary exchange reaction establishes a network of transitions and adds a layer of connectivity between the elements of the microcanonical table. These connections form a graph whose nodes are configurations, and its edges represent individual exchange reactions. The graph has the following properties: 1.
It is bidirectional because the reverse of the exchange reaction is also a binary exchange reaction.

Random Walk on the Binary Exchange Reaction Graph
To sample the microcanonical table, we construct a random walk on the graph of binary exchange reactions, but in order to visit configurations with proper microcanonical probability, we must construct an appropriate transition probability. We begin by defining the equilibrium constant of the transition in Equation (23) as where w i and w j are the cluster weights of the products and w i and w j are those of the reactant clusters. According to Equation (9), the selection functional of the configuration is the product of the multiplicity of its elements, and since the product and reactant distributions differ only in the mass of elements that participate in in the reaction, the final result has the form of the familiar reaction equilibrium constant with the activities of chemical species replaced by the multiplicities of the elements of the configuration. We now set the transition probability for the reaction c → c by the Metropolis prescription: The detailed balance condition: is satisfied by the microcanonical probability in Equation (12). It follows [20] that the microcanonical probability is the stationary probability of the Markov process described by the transition probabilities from Equation (25): a random walk that starts from any configuration visits in the long run every configuration according to its microcanonical probability.

Monte Carlo Sampling
The exchange reaction can be simulated easily by the Monte Carlo method. We begin with an arbitrary configuration of N ordered integers, pick at random two elements, i and j, and replace them by two new numbers i and j such that i + j = i + j. To implement this numerically, we draw an integer random number 1 < r < i + j and set i = r, j = i + j − r. If i = i, we reject the result and repeat with a new random number in order to avoid self transitions. However, this step is not necessary because self transitions do not alter the stationary distribution: the probability of self transition is 1/(z + 1), where z = (M − N)(N − 1) is the number of cross-transitions; this number is the same for all configurations and affects all distributions uniformly. This simplifies the simulation by allowing the transfer of any mass between two clusters.
With w i = 1, the selection functional is W(n) = 1 for all n and distributions are sampled in proportion to their multinomial factor. By choosing the selection functional appropriately, we can bias the probability of the distribution towards any distribution of the ensemble. We demonstrate the effect of the selection functional for the case M = 7, N = 5. The microcanonical ensemble contains two distributions, n A = (4, 0, 1) and n B = (3, 2, 1) with n A ! = 5, n B ! = 10 and with corresponding probabilities 1/3 and 2/3, respectively. We construct the selection functional using w i = i α . This leads to the following probabilities for the two distributions: Positive exponents favor the probability of n A ; in the limit α → ∞, we obtain P(n A ) → 1, and similarly, with α → −∞, we obtained P(n B ) → 1. We illustrate this behavior in Figure 2 using Monte Carlo sampling to track the number of times each configuration is visited. With α = 1, all configurations are visited with the same probability. With α > 0, the configurations with distribution n B = (3, 2, 0) are visited more frequently than those with distribution n A = (4, 1, 1). With a < 0, the bias shifts towards configurations with distribution n A . In all cases, the configurations within the same distributions are equiprobable.

Microcanonical Thermodynamics
In the asymptotic limit M, N → ∞ at fixed M/N, the discrete ensemble of distributions is quasi continuous in n and Ω M,N may be treated as a continuous function of M and N. We define the parameters β and q as By Taylor's expansion, we have which is valid for k M, l N. Applying this result with l = 1 to Equation (13), we obtain the mean distribution in the form: The factors β and log q are obtained from the conditions: which express the fact that n k /N is normalized to unity and its mean is M/N. The mean distribution is uniquely determined by the weights w k and the mean cluster size. This further implies that β and log q, both of which are derivatives of log Ω M,N , are functions of the ratio M/N, i.e., they are homogeneous in M and N with degree 0. It follows that log Ω M,N is homogeneous in M and N with degree one, then, by Euler's theorem for homogeneous functions, we obtain log Ω M,N = Mβ + N log q.
A consequence of homogeneity is that the mean distribution in the asymptotic limit is overwhelmingly more probable than any other distributions. To see why, we calculate the log of the probability of distribution n by combining Equations (10) and (30): whose right-hand side is zero by virtue of of Equation (32). Effectively, the selection functional picks out a single distribution from the microcanonical table and renders all others invisible. The inequality log P(n) < log P( n ), which merely states that all other distributions of the ensemble are less probable that the mean distribution, can be expressed in the equivalent form: where S(n) is the extensive Shannon functional of distribution n: The inequality in Equation (34) is a statement of the second law: the functional on the left-hand side is maximized by the mean distribution in Equation (30). In the special case W(n) = 1, Equation (34) states that the Shannon entropy of the mean distribution is the highest among all distributions in the ensemble.

Canonical Thermodynamics
We return to the canonical probability in Equation (17). Using Equation (32) to write log Ω M−M ,N−N = −βM − N log q, the canonical probability in the asymptotic limit is The canonical probability in the asymptotic limit is proportional to the microcanonical weight and the Boltzmann factor e −βM , where M is the total mass in the configuration. We obtained the canonical partition function by returning to Equation (21) in combination with Equation (32): Here, the notation Q N ,β implies that the canonical partition function does not depend on M and N individually, but on the intensive variable β, a function of the intensive ratio M/N. We now recognize the parameter q, which was defined as the partial derivative of Ω M,N , as the canonical partition function in a single column of the microcanonical table.

Construction of the Selection Functional
The microcanonical table asymptotically contains every normalized distribution f k with meank = M/N. We will construct a selection functional that picks any distribution f * k from this space. We begin by setting where a > 0 and b are arbitrary constants. It is a simple matter to confirm that this form satisfies Equation (30) with n k /N = f * k , q = a, and β = b. Since we are free to select a and b, we choose a = 1, b = 0, which gives w * k = f * k . Thus, we have a straightforward way to construct equilibrium constants for the exchange reaction so as to target any distribution as the equilibrium distribution. The only requirement is that the distribution has a finite mean.
We demonstrate the use of Equation (38) with two examples. In the first example, we consider the triangular distribution: with support in 100 ≤ k ≤ 300 and meank = 200. To simulate this distribution by the exchange reaction method, we use a list of N = 1000 clusters with total mass M = 200N so that the mean cluster in the list is 200, as in the distribution. We set w k = f k if f k > 0 and w k = 10 −10 if f k = 0 (the cluster weight appears in the denominator of the equilibrium constant and cannot be zero). The simulation begins with the mass of all clusters set tō k = 200. Figure 3a shows the results of the simulation after 4 × 10 5 steps and demonstrates very good agreement with the distribution for which the selection functional was constructed. For the second example, we construct a bimodal distribution formed as a mixture of two Gaussian distributions in equal proportions, one centered at k 1 = 180 with variance σ 2 1 = 100, the other one centered at k 2 = 220 with variance σ 2 2 = 1000. The mean of the bimodal distribution isk = 200. The simulation is again conducted with N = 1000 particles with total mass M = 200N, starting with all particles at massk = 200. Figure 3b shows that, in this case, as well, the simulated distribution converges to the distribution for which the w k values were designed.

Discussion
The set of integer partitions illustrates the structure of thermodynamic ensembles and the emergence of the thermodynamic limit. The table of ordered partitions represents the microcanonical ensemble; any number of columns extracted from this table forms a canonical ensemble. The equivalence between these ensembles is established by the elementary property that all columns of the table of ordered partitions contain the same list of clusters. The classical proof requires the study of fluctuations in the thermodynamic limit. Here, we have established equivalence in the discrete finite domain.
We have assigned probabilities in proportion to the microcanonical functional n!W(n). The standard mathematical treatment [14] does not distinguish between n! and W(n) individually. This is not a trivial mathematical detail. The multinomial coefficient arises because we treat permutations in the order of the partitions as distinct from each other. It is only when we take the order of partitions into consideration that the microcanonical table presented a structure with well-defined combinatorial properties. The reference ensemble is defined by the condition W = 1. This renders all ordered partitions equally probable; the multiplicity of the distribution is given by the multinomial coefficient, and the most-probable distribution is exponential. This is Boltzmann's derivation of combinatorial entropy [21] (p. 55). Thus, we make contact with a fundamental result of statistical mechanics. The uniform selection functional is the mathematical statement of the postulate of equal a priori probabilities. The mostprobable distribution in this case is the distribution with the maximum multinomial coefficient, and since its logarithm is the entropy functional, we concluded that the mostprobable distribution in the microcanonical table under a uniform prior is the maximum entropy distribution. The selection functional biases the probability of configurations relative to that in the reference ensemble and can be designed to deliver any distribution present in the ensemble as the most-probable distribution in the thermodynamic limit. This was shown previously within an abstract space of distributions [22]; we have obtained the same result in the space of distributions contained in the microcanonical table. The exchange reaction serves to highlight the connection between integer partitions and thermodynamics in a physical way. We imagine integer partitions to represent a collection of clusters and the exchange reaction to represent a reversible reaction between them. The selection functional is the chemical "activity" of the clusters and determines the equilibrium constant of the reaction. Importantly, only the selection functional appears in the equilibrium constant. This is yet another reason for treating the multinomial coefficient and the selection functional as two separate functionals: The multinomial factor accounts for the random selection of the clusters chosen to react and represents what in thermodynamics we call an "ideal" system; the selection functional expresses deviations from ideality by imposing a bias relative to a purely random system. This is most clearly expressed in Equation (30), in which the factor w k can be viewed as a correction to the exponential distribution e −βk /q because of nonidealities.
In a further departure from the standard mathematical literature, we have provided an exact treatment of discrete finite ensembles of partitions, including ensembles that are too small to be treated as continuous. The microcanonical probability is given in Equation (10) and the canonical probability in Equation (17). The mean distribution is given by Equation (22), while the most-probable distribution is defined by the condition max n n!W(n) and satisfies the second law in Equation (34) as a strict inequality. All of these results apply to ensembles of any size. The thermodynamic limit requires n i to be large enough (equivalently, M, N 1) that it may be treated as a continuous variable. To demonstrate the transition from the discrete/finite to discrete/infinite and, finally, to continuous/infinite domain, we consider the case W(n) = 1 for which the partition function is given in Equation (1). Applying Equation (13) with w i = 1, we obtain the mean distribution in the form: Under the last condition, the cluster mass may be treated as a continuous variable, and thus, we recover the exponential distribution as the most-probable distribution in the unbiased ensemble.

Conclusions
In summary, we have formulated the combinatorial properties of the ensemble of integer partitions. By considering ordered partitions, we obtain an organized tabulation such that the table itself is a microcanonical ensemble and its rows are canonical ensembles. The ensemble is a container of distributions and contains a discrete finite sample of all distributions with finite mean and support on the real axis. The natural multiplicity of the distribution in the ensemble is its multinomial coefficient, and its logarithm is the entropy of the distribution. By further biasing the probability of the distribution via the selection functional, we can select any distribution from this ensemble. In the asymptotic limit, the space of distributions obeys thermodynamics: it gives rise to a distribution that is overwhelmingly more probable than all others and whose parameters satisfy the familiar thermodynamic relationships. We may view the ensemble of partitions as a generic template for stochastic processes. The central quantity in any stochastic process is the probability distribution of a stochastic variable, which may be thought to arise from the ensemble of partitions under a suitable functional. The determination of this functional is the challenge in this approach, but if this functional could be identified, we would obtain a rigorous thermodynamic treatment of the process. A few examples have been given in the literature of population balances [5,10,11,23]. We suggest that this approach can be extended beyond population balances to stochastic processes in general.